package com.example.repositories;

import java.util.Collection;
import java.util.Date;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.repository.CrudRepository;

import com.example.models.Product;

public interface ProductRepository extends MongoRepository<Product, String>{
//public interface ProductRepository extends JpaRepository<Product, Long>{
//info: http://docs.spring.io/spring-data/jpa/docs/current/reference/html/
//mongo ifno: http://docs.spring.io/spring-data/mongodb/docs/1.2.x/reference/html/mongo.repositories.html
	  Collection<Product> findByCategory(String category);
	  Collection<Product> findByCategoryLike(String pattern);
	  Collection<Product> findByName(String name);
	  Collection<Product> findByNameLike(String pattern);
	  Collection<Product> findByNameAndCategory(String name, String category);
	  Collection<Product> findByNameOrCategory(String name, String category);
	  Collection<Product> findByExpirationDateBetween(Date date1, Date date2);
	  Collection<Product> findByExpirationDateBefore(Date date);
	  Collection<Product> findByExpirationDateAfter(Date date);
	  Product findByIdAndStock(String id, Integer stock);
	  Collection<Product> findByStockGreaterThan(int stock);
	  Collection<Product> findByStockLessThan(int stock);
//	  Collection<Product> findByStockLessThanAndStockGreaterThan(int inf, int sup);
	  Collection<Product> findByStockBetween(int inf, int sup);
}
